package base

import (
	. "lambda"
)

var (
	IDENTITY = Abs(Ref(1))

	TRUE  = Abs(Abs(Ref(2)))
	FALSE = Abs(Abs(Ref(1)))

	CONS = Abs(Abs(Abs(App(App(Ref(1), Ref(3)), Ref(2)))))
	CAR  = Abs(App(Ref(1), TRUE))
	CDR  = Abs(App(Ref(1), FALSE))

	OMEGA = Abs(App(Ref(1), Ref(1)))
	LOOP  = App(OMEGA, OMEGA)
)

func Cons(car, cdr Term) Term {
	return App(App(CONS, car), cdr)
}

func Car(cons Term) Term {
	return App(CAR, cons)
}

func Cdr(cons Term) Term {
	return App(CDR, cons)
}

func PrimByte(n byte) Primitive {
	return Prim([]byte{n})
}

func PrimString(str string) Primitive {
	return Prim([]byte(str))
}
